package com.lanyam.travel.base.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.lanyam.travel.base.dao.OrderUserMapper;
import com.lanyam.travel.base.entity.OrderUser;
import com.lanyam.travel.base.service.IOrderUserService;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author rosson
 * @since 2020-01-27
 */
@Service
public class OrderUserServiceImpl implements IOrderUserService {

	@Autowired
	private OrderUserMapper orderUserMapper;
	
	@Override
	public void batchAddOrderUser(List<OrderUser> usersInOrder) {
		// TODO Auto-generated method stub
		for (OrderUser orderUser : usersInOrder) {
			orderUserMapper.insert(orderUser);
		}
	}

	@Override
	public List<OrderUser> getOrderUserByOrderId(String orderId) {
		// TODO Auto-generated method stub
		QueryWrapper<OrderUser> wrapper = new QueryWrapper<OrderUser>();
		wrapper.eq("order_id", orderId);
		return orderUserMapper.selectList(wrapper);
	}

	@Override
	public OrderUser getOrderUserById(String id) {
		// TODO Auto-generated method stub
		return orderUserMapper.selectById(id);
	}

	@Override
	public void deleteOrderUserById(String id) {
		// TODO Auto-generated method stub
		orderUserMapper.deleteById(id);
	}

	@Override
	public void deleteOrderUserByOrderId(String orderId) {
		// TODO Auto-generated method stub
		QueryWrapper<OrderUser> wrapper = new QueryWrapper<OrderUser>();
		wrapper.eq("order_id", orderId);
		orderUserMapper.delete(wrapper);
	}

	@Override
	public void updateOrderUser(OrderUser orderUser) {
		// TODO Auto-generated method stub
		orderUserMapper.updateById(orderUser);
	}

}
